<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0px;
				padding: 0px;
			}
			.box{
				width: 500px;
				height: 500px;
				border: 5px solid red;
				margin-left: 200px;
				margin-top: 100px;
				position: relative;
			}
			.small{
				width: 200px;
				height: 200px;
				background: yellow;
				/*margin-left: 100px;*/
				/*margin-top:50px ;*/
				position: absolute;
				top: 50px;
				left: 50px;
					
				
				
			}
		</style>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				$('.box').click(function(){
//					获得当前元素看距离文档顶部的距离
					var t = $('.small').offset().top;
//					获得当前元素看距离文档左侧的距离
					var l = $('.small').offset().left;
//					获得当前元素的top值
					var pt = $('.small').position().top
//					获得当前元素的left值
					var pl = $('.small').position().left
					console.log(pt)
				})
			})
		</script>
	</head>
	<body>
		<div class="box">
			<div class="small">
				
			</div>
		</div>
	</body>
</html>
